package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.ApiOrderDirect;
import com.sc.nft.enums.ApiOrderStateEnum;
import com.sc.nft.mapper.ApiOrderDirectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 福禄订单DAO
 *
 * @author liGen
 * @version 1.0
 * @date 2023/11/15 1:35 下午
 */
@Slf4j
@Repository
public class ApiOrderDirectDao extends ServiceImpl<ApiOrderDirectMapper, ApiOrderDirect> {

    public ApiOrderDirect getByOrderId(Long orderId) {
        LambdaQueryWrapper<ApiOrderDirect> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ApiOrderDirect::getOrderId,orderId);
        return baseMapper.selectOne(wrapper);
    }

    public ApiOrderDirect getByOrderNo(String orderNo) {
        LambdaQueryWrapper<ApiOrderDirect> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ApiOrderDirect::getOrderNo,orderNo);
        return baseMapper.selectOne(wrapper);
    }

    public List<ApiOrderDirect> getByApiOrderState(ApiOrderStateEnum apiOrderStateEnum) {
        LambdaQueryWrapper<ApiOrderDirect> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ApiOrderDirect::getApiOrderState,apiOrderStateEnum.getCode());
        return baseMapper.selectList(wrapper);
    }
}